package com.xayy.ds.controller;

import cn.kawins.base.result.ResultBody;
import com.xayy.mgt.model.vo.HealthDeepVo;
import com.xtck.ha.common.core.constant.HttpStatus;
import com.xtck.ha.common.core.utils.poi.ExcelUtil;
import com.xtck.ha.common.core.web.controller.BaseController;
import com.xtck.ha.common.core.web.domain.AjaxResult;
import com.xtck.ha.common.core.web.page.TableDataInfo;
import com.xayy.ds.model.DsHealthDeep;
import com.xayy.ds.service.DsHealthDeepService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 模型列表 controller
 *
 * @ClassName: DsHealthDeepController
 * @Description: 外部访问接口
 * @author liuyuan
 * @date 2025-07-03
 */
@Api(tags = "深度健康评估表管理")
@RestController
@RequestMapping("/api/v1.0/jkd")
public class DsHealthDeepController extends BaseController {

    @Autowired
    private DsHealthDeepService dsHealthDeepService;


    @ApiOperation("分页查询深度健康评估表列表")
    @GetMapping("/page")
    public AjaxResult page(DsHealthDeep dsHealthDeep)
    {
        startPage();
        List<DsHealthDeep> list = dsHealthDeepService.selectTList(dsHealthDeep);
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(HttpStatus.SUCCESS);
        rspData.setList(list);
        rspData.setMsg("查询成功");
        rspData.setTotal(dsHealthDeepService.count(dsHealthDeep));
        return AjaxResult.success(rspData);
    }

    @ApiOperation("列表查询深度健康评估表")
    @GetMapping("/list")
    public List<DsHealthDeep> list(DsHealthDeep dsHealthDeep)
    {
        List<DsHealthDeep> list = dsHealthDeepService.selectTList(dsHealthDeep);
        return list;
    }

    @ApiOperation("导出深度健康评估表列表")
    @PostMapping("/export")
    public void export(HttpServletResponse response, DsHealthDeep dsHealthDeep)
    {
        List<DsHealthDeep> list = dsHealthDeepService.selectTList(dsHealthDeep);
        ExcelUtil<DsHealthDeep> util = new ExcelUtil<>(DsHealthDeep.class);
        util.exportExcel(response, list, "样例数据");
    }

    @ApiOperation("获取$深度健康评估表详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dsHealthDeepService.selectTById(id));
    }

    @ApiOperation("新增$深度健康评估表")
    @PostMapping
    public AjaxResult add(@RequestBody DsHealthDeep dsHealthDeep)
    {
        return toAjax(dsHealthDeepService.insertT(dsHealthDeep));
    }

    @ApiOperation("修改深度健康评估表")
    @PutMapping
    public AjaxResult update(@RequestBody DsHealthDeep dsHealthDeep)
    {
        int i = dsHealthDeepService.updateT(dsHealthDeep);
        return toAjax(i);
    }

    @ApiOperation("删除深度健康评估表")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dsHealthDeepService.deleteTByIds(ids));
    }


    @PostMapping("/saveHealthDeep")
    @ApiOperation(value = "新增健康度")
    public ResultBody saveHealthDeep(@RequestBody HealthDeepVo healthDeepVo) {
        return dsHealthDeepService.saveHealthDeep(healthDeepVo).body();
    }

    @PutMapping("/updateHealthDeep")
    @ApiOperation(value = "修改健康度")
    public ResultBody updateHealthDeep(@RequestBody HealthDeepVo healthDeepVo) {
        return dsHealthDeepService.updateHealthDeep(healthDeepVo).body();
    }

    @GetMapping("/getHealthDeep/{nodeId}")
    @ApiOperation(value = "查看健康度详情")
    public ResultBody getHealthDeep(@PathVariable Long nodeId) {
        return dsHealthDeepService.getHealthDeepVo(nodeId).body();
    }



}
